//
//  Singleton.h
//  DesignModel
//
//  Created by 赵明明 on 2022/1/5.
//

#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN

#define DEFINE_SINGLETON_HEADER(className) \
\
+ (className *)shared##className;
 
#define DEFINE_SINGLETON_IMPLEMENTATION(className) \
\
static className *shared##className = nil; \
static dispatch_once_t pred; \
\
+ (className *)shared##className { \
    dispatch_once(&pred, ^{ \
        shared##className = [[super allocWithZone:NULL] init]; \
    }); \
    return shared##className; \
} \
\
+ (id)allocWithZone:(NSZone *)zone { \
    return [self shared##className];\
} \
\
- (id)copyWithZone:(NSZone *)zone { \
return self; \
}


@interface Singleton : NSObject
@property NSInteger *mInt;
+(Singleton * )getInstance;
+ (id)allocWithZone:(NSZone *)zone;
- (id)copyWithZone:(NSZone *)zone;
- (instancetype)init;
@end

NS_ASSUME_NONNULL_END
